﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;
using System.Linq.Expressions;
using SBACN.WebSite.Models;
using SBACN.WebSite.Code;

namespace SBACN.WebSite.Handler.Admin
{
    /// <summary>
    /// AutoCompleteMemberCompany 的摘要说明
    /// </summary>
    public class AutoCompleteMemberCompany : BaseHandler
    {
        public override void Process()
        {
            HttpContext context = base.httpContext;
            context.Response.ContentType = "text/json";
            var Term = context.Request.QueryString["term"].Trim();
            Expression<Func<TB_Member, bool>> f = (p =>p.Name.Contains(Term));
            Expression<Func<TB_Member, int>> order = (p => p.ID);

            var result = DAL.DALHelper.Instance.GetList<TB_Member, int>(f, order, true)
                .Select(c => (new { value = c.Name, id = c.ID }));
            string str = JsonConvert.SerializeObject(result);
            context.Response.Write(str);
        }
    }
}